import Vue from 'vue'
import Router from 'vue-router'
import login from '@/components/view/login'
import layout from '@/components/view/layout'

Vue.use(Router)

// 任何角色都能访问路由表
export const syncRouterMap = [
  {
    path: '/',
    name: 'login',
    component: login,
    hidden: true
  },
  {
    name: 'desktop',
    path: '/desktop',
    component: layout,
    meta: {
      name: '主页面板',
      icon: 'el-icon-tableware'
    },
    children: [
      {
        name: 'desktop-index',
        path: '',
        component: () => import('@/components/view/desktop')
      }
    ],
    redirect: '/desktop/'
  },
  {
    path: '/system',
    name: 'system',
    component: layout,
    meta: {
      name: '系统设置',
      icon: 'el-icon-sugar'
    },
    children: [
      {
        path: 'userList',
        name: 'userList',
        meta: { name: '用户列表', icon: 'el-icon-dessert' },
        component: () => import('@/components/view/user/userList')
      },
      {
        path: 'about',
        name: 'about',
        meta: { name: '个人资料', icon: 'el-icon-ice-cream' },
        component: () => import('@/components/view/user/about')
      }
    ]
  },
  {
    path: '/my-components',
    name: 'myComponents',
    component: layout,
    meta: { name: '业务组件', icon: 'el-icon-hot-water' },
    children: [
      {
        path: 'table',
        name: 'my-table',
        meta: { name: '可编辑表格', icon: 'el-icon-water-cup' },
        component: () => import('@/components/view/my/table')
      },
      {
        path: 'search',
        name: 'search',
        meta: { name: '检索组件', icon: 'el-icon-cold-drink' },
        component: () => import('@/components/view/my/search')
      },
      {
        path: 'echarts',
        name: 'echarts',
        meta: { name: 'echarts图表', icon: 'el-icon-cold-drink' },
        component: () => import('@/components/view/echarts')
      },
      {
        path: 'hand-drawn',
        name: 'drawn',
        meta: { name: '手绘图表', icon: 'el-icon-cold-drink' },
        component: () => import('@/components/view/echarts/drawn')
      }
    ]
  }
]

export default new Router({
  mode: 'history',
  routes: syncRouterMap
})
